package com.mall.express;

import com.mall.entity.LoginUser;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;

import java.util.List;

@Component("maxAnger")
public class SecurityExpress {
    public boolean hasAuthority(String role){
        //从上下文中获取用户的信息；
        LoginUser principal = (LoginUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        //获取用户的权限信息
        List<String> premission = principal.getPremission();
        return premission.contains(role);
    }
}
